package com.hdl.demo;

/**
 * 类名 DemoApplication
 * 描述 TODO
 *
 * @author hedonglin
 * @version 1.0
 * @date 2020/4/27 9:54
 */

import cn.com.bsfit.netty.NettyApp;
import cn.com.bsfit.netty.config.base.BaseConfigurable;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.Banner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.FilterType;

/**
 * 类名 NettyApp
 * 描述 主程序启动类
 *
 * @author hedonglin
 * @version 1.0
 * @date 2019/9/29 9:43
 */
@Slf4j
@EnableAutoConfiguration
@ComponentScan(basePackages = {"cn.*", "com.*", "net.*"},
        // 不适用默认的过滤器
        useDefaultFilters = false,
        //includeFilters 只扫描指定的类
        includeFilters = {
                // 只有实现了BaseConfigurable接口的类才回被扫描
                @ComponentScan.Filter(value = {BaseConfigurable.class},
                        // 过滤类型为指定的类型，比如某个类
                        type = FilterType.ASSIGNABLE_TYPE)}
         ,
        // 不扫描NettyApp.class(重要)
        excludeFilters = {
                @ComponentScan.Filter(classes = NettyApp.class)
        }
)
public class DemoApplication {
    public static void main(String[] args) {
        try {
            SpringApplication app = new SpringApplicationBuilder().bannerMode(Banner.Mode.OFF).sources(NettyApp.class).build();
            app.run(args);
        } catch (Exception e) {
            log.error("请确认已正确配置该应用，请检查是否正确配置");
        }
    }
}
